package server.qiang.email;

import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Transport;
import java.util.Properties;


public class Checkmail {


	public boolean sendcheckMail(String x, String y, String z) {

		Properties props = new Properties();
		//设置连接参数
		props.setProperty("mail.host", x);
		props.setProperty("mail.transport.protocol", "smtp");
		props.setProperty("mail.smtp.auth", "true");
		//获取session
		Session session = Session.getDefaultInstance(props);
		//获取Transport对象
		Transport transport = null;


		try {
			transport = session.getTransport();
		} catch (NoSuchProviderException e1) {

			return false;
		}


		//连接邮件smtp服务器，参数分别为服务器地址，用户名和密码
		try {
			transport.connect(x, y, z);
		} catch (MessagingException e) {

			return false;
		}


		if (transport.isConnected()) {

			return true;
		} else {

			return false;

		}
		//关闭连接


	}


}


